﻿package plugin.union.game
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.union.*;
    import uiresource.union.*;

    public class UnionNewsGame extends UnionNewsUI
    {
        private var _instance:UnionNews;

        public function UnionNewsGame(param1:UnionNews)
        {
            this._instance = param1;
            this.initEvent();
            return;
        }// end function

        private function initEvent() : void
        {
            btn_close.clickHandler = new Handler(this._instance.close);
            btn_onekey.clickHandler = new Handler(this.doOper);
            return;
        }// end function

        private function doOper() : void
        {
            var _loc_3:Object = null;
            var _loc_1:* = ModelProxy.getValue("data", "unionApplyList");
            var _loc_2:Array = [];
            for each (_loc_3 in _loc_1)
            {
                
                _loc_2.push(_loc_3.rid);
            }
            UnionSender._9agreeAdd(_loc_2);
            return;
        }// end function

        public function refresh() : void
        {
            var _loc_1:* = ModelProxy.getValue("data", "unionApplyList");
            list_apply.array = _loc_1 as Array;
            list_apply.renderHandler = new Handler(this.applyRender);
            return;
        }// end function

        private function applyRender(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:ApplyItemUI = null;
            if (param2 < list_apply.length)
            {
                _loc_3 = list_apply.array[param2];
                _loc_4 = param1.getChildByName("item") as ApplyItemUI;
                _loc_4.txt_name.text = _loc_3.name;
                _loc_4.txt_num.text = _loc_3.nbValue;
                _loc_4.txt_lv.text = _loc_3.reinLevel + "转" + _loc_3.level + "级";
                _loc_4.txt_career.text = UIGlobel.getCareer(_loc_3.career);
                _loc_4.txt_time.text = TimeDataFormatUtil.getTimeStr(_loc_3.applyTime);
                _loc_4.agree.addEventListener(MouseEvent.CLICK, this.doAgree);
                _loc_4.agree.dataSource = _loc_3;
                _loc_4.refuse.addEventListener(MouseEvent.CLICK, this.doRefuse);
                _loc_4.refuse.dataSource = _loc_3;
            }
            return;
        }// end function

        protected function doRefuse(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget.dataSource;
            UnionSender._10refuseAdd([_loc_2.rid]);
            return;
        }// end function

        protected function doAgree(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget.dataSource;
            UnionSender._9agreeAdd([_loc_2.rid]);
            return;
        }// end function

    }
}
